/*package com.wsjc.web.controller;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.aliyun.oss.common.utils.DateUtil;
import com.wsjc.common.core.entity.ApiCommonResultVo;
import com.wsjc.manager.entity.WjEmployers;
import com.wsjc.manager.entity.WjHospital;
import com.wsjc.manager.entity.WjUser;
import com.wsjc.manager.service.pc.employers.PcService;

@RestController
@RequestMapping(value = "/pc/")
public class PcEmployersController {

	private static Logger logger = LoggerFactory.getLogger(PcEmployersController.class);

	@Autowired
	private PcService pcService;

	@Autowired
	private HelpService helpService;
	
	

	@InitBinder
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
		// 对于需要转换为Date类型的属性，使用DateEditor进行处理
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		CustomDateEditor editor = new CustomDateEditor(df, false);
		binder.registerCustomEditor(Date.class, editor);
	}


	

	*//**
	 * 2.3 Pc 监察单位的联系人清单信息查询 请求方式 ：GET 参数 ：partID : 单位ID , Key 软件秘钥
	 * 
	 * @return 0 不成功 list(2--x) 空 , 1 成功 list(2-x) 给值 Contact 联系人+电话
	 *//*
	@RequestMapping(value = "findUserByEmployersID", method = RequestMethod.GET)
	public ApiCommonResultVo findUserByEmployersID(String PartID, String Key) {
		logger.info("PC接口 :2.3 " + DateUtil.formatAlternativeIso8601Date(null));
		// 处理空格
		PartID = PartID.replace(" ", "");
		// 处理PartID 大小写
		ApiCommonResultVo resultCommon = null;
		try {
			// 处理卫监单位ID 前两个大写，后几位小写。
			PartID = PartID.substring(0,1).toUpperCase().concat(PartID.substring(1).toLowerCase());
			WjEmployers wjEmployers = pcService.findEmployersById(PartID);
			if (null == wjEmployers) {
				resultCommon = new ApiCommonResultVo(0, "", "单位不存在");
				return resultCommon;
			}
			if (!wjEmployers.getKey().equals(Key)) {
				resultCommon = new ApiCommonResultVo(0, "", "秘钥不合法");
				return resultCommon;
			}
			List<WjUser> lUsers = pcService.findUserByEmployersID(wjEmployers.getId());
			if (null == lUsers) {
				resultCommon = new ApiCommonResultVo(0, null, "暂无数据");
				return resultCommon;
			}
			resultCommon = new ApiCommonResultVo(0, "", "");
		} catch (Exception e) {
			resultCommon = new ApiCommonResultVo(0, "", "用户名异常");
			logger.info("捕获异常：" + DateUtil.formatAlternativeIso8601Date(null) + " " + e.getMessage());
			return resultCommon;
		}
		return resultCommon;
	}

	*//**
	 * 2.4 Pc 监察单位查看自己的单位信息 请求方式 ：GET 参数 ：partID : 单位ID , Key 软件秘钥
	 * 
	 * @return 0 不成功 list(2--3) 空 , 1 成功 list(2-3) 给值 2:Address 3:Partstyle
	 *         4:MeasurementNo 5:MeasurementLimit 6:UsedPeriod
	 * 
	 *//*
	@RequestMapping(value = "findEmployersInfoByID", method = RequestMethod.GET)
	public Map<String, Object> findEmployersInfoByID(String PartID, String Key) {
		log.info("PC接口 :2.4 " + DateUtil.getTime());
		// 处理空格
		PartID = PartID.replace(" ", "");
		// 处理PartID 大小写
		Map<String, Object> resultMap = null;
		try {
			PartID = HelpUtil.TreateEmployerID(PartID);
			System.out.println(" 处理之后的  KEY " + Key);
			System.out.println(" 处理之后的  PartID " + PartID);
			System.out.println("传递过来的参数 ： PartID : " + PartID + " ,  Key :" + Key);
			Employers employers = pcService.findEmployersById(PartID);
			System.out.println("获取到的  卫监单位信息 ：" + employers);
			if (null == employers) {
				resultMap = MapModel.getMapModel("0", "", "单位不存在");
				return resultMap;
			}
			if (!employers.getKey().equals(Key)) {
				resultMap = MapModel.getMapModel("0", "", "秘钥不合法");
				return resultMap;
			}
			resultMap = MapModel.getMapModel("1", employers, "");
		} catch (Exception e) {
			resultMap = MapModel.getMapModel("0", "", "用户名异常");
			log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
			return resultMap;
		}
		return resultMap;
	}

	*//**
	 * 2.5 Pc 监察单位查询辖区被检察单位目录 请求方式 ：GET 参数 ：partID : 单位ID , Key 软件秘钥
	 * 
	 * @return 0 不成功 list(2--x) 空 , 1 成功 list(2-x) 给值 PartName : 被检察单位名称 + 单位ID
	 *//*
	@RequestMapping(value = "findHospitalByemployersID", method = RequestMethod.GET)
	public Map<String, Object> findHospitalByemployersID(String PartID, String Key) {
		log.info("PC接口 :2.5 " + DateUtil.getTime());
		// 处理空格
		PartID = PartID.replace(" ", "");
		// 处理PartID 大小写
		Map<String, Object> resultMap = null;
		try {
			PartID = HelpUtil.TreateEmployerID(PartID);
			Employers employers = null;
			Map<String, Object> paramsMap = new HashMap<String, Object>();
			employers = pcService.findEmployersById(PartID);
			System.out.println("获取到的  卫监单位信息 ：" + employers);
			if (null == employers) {
				resultMap = MapModel.getMapModel("0", "", "单位不存在");
				return resultMap;
			}
			if (!employers.getKey().equals(Key)) {
				resultMap = MapModel.getMapModel("0", "", "秘钥不合法");
				return resultMap;
			}
			// 获取数据
			if (employers.getEmployers_grade().equals("1")) { // 全国的。
				List<Province> lProvinces = helpService.selectAllProvince();
				List<Hospital> list = new ArrayList<Hospital>();
				for (Province province : lProvinces) {
					String province_id = province.getProvince_id();
					int is_municipal = helpService.getIs_municipalByProvince_id(province_id);
					if (is_municipal == 1) {
						List<Hospital> hospitals = null;
						paramsMap.put("t_hospital", Constants.T_HOSPITAL + province_id);
						try {
							hospitals = pcService.findHospitalByRetrieve(paramsMap);
						} catch (Exception e) {
							log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
							continue;
						}
						for (Hospital h : hospitals) {
							String h_id = province_id + h.getHospital_id();
							h.setHospital_id(h_id);
						}
						list.addAll(hospitals);
						continue;
					}
					// 获取所有表名
					List<City> lCities = helpService.findCityByProvince_id(province_id);
					for (City city : lCities) { // 遍历 表
						String c_id = city.getCity_id(); // 市 ID
						paramsMap.put("t_hospital", Constants.T_HOSPITAL + c_id);
						List<Hospital> lh = null;
						try {
							lh = pcService.findHospitalByRetrieve(paramsMap);
						} catch (Exception e) {
							log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
							continue;
						}
						for (Hospital h : lh) {
							String h_id = c_id + h.getHospital_id();
							h.setHospital_id(h_id);
						}
						list.addAll(lh);
					}
				}
				resultMap = MapModel.getMapModel("1", list, "");
				return resultMap;
			} else if (employers.getEmployers_grade().equals("2")) { // 省级的
				String province_id = employers.getEmployers_id().substring(1, 7);
				int is_municipal = helpService.getIs_municipalByProvince_id(province_id);
				List<Hospital> list = new ArrayList<Hospital>();
				if (is_municipal == 1) {
					paramsMap.put("t_hospital", Constants.T_HOSPITAL + province_id);
					try {
						list = pcService.findHospitalByRetrieve(paramsMap);
					} catch (Exception e) {
						log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
						return resultMap = MapModel.getMapModel("0", list, "正在建设中，请耐心等待！");
					}
					for (Hospital h : list) {
						String h_id = province_id + h.getHospital_id();
						h.setHospital_id(h_id);
					}
					resultMap = MapModel.getMapModel("1", list, "");
					return resultMap;
				}
				// 获取所有表名
				List<City> lCities = helpService.findCityByProvince_id(province_id);
				for (City city : lCities) { // 遍历 表
					String c_id = city.getCity_id(); // 市 ID
					paramsMap.put("t_hospital", Constants.T_HOSPITAL + c_id);
					List<Hospital> lh = null;
					try {
						lh = pcService.findHospitalByRetrieve(paramsMap);
					} catch (Exception e) {
						log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
						continue;
					}
					for (Hospital h : lh) {
						String h_id = c_id + h.getHospital_id();
						h.setHospital_id(h_id);
					}
					list.addAll(lh);
				}
				resultMap = MapModel.getMapModel("1", list, "");
				return resultMap;
			} else if (employers.getEmployers_grade().equals("3")) { // 市级的
				String c_id = employers.getEmployers_id().substring(1, 5) + "00";
				paramsMap.put("t_hospital", Constants.T_HOSPITAL + c_id);
				List<Hospital> list = null;
				try {
					list = pcService.findHospitalByRetrieve(paramsMap);
				} catch (Exception e) {
					log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
					return resultMap = MapModel.getMapModel("0", list, "正在建设中，请耐心等待！");
				}
				for (Hospital h : list) {
					String h_id = c_id + h.getHospital_id();
					h.setHospital_id(h_id);
				}
				resultMap = MapModel.getMapModel("1", list, "");
				return resultMap;
			} else if (employers.getEmployers_grade().equals("4")) { // 区级的
				String province_id = employers.getEmployers_id().substring(1, 3).toString() + "0000";
				String c_id = employers.getEmployers_id().substring(1, 5) + "00";
				String area_id = employers.getEmployers_id().substring(1, 7);
				paramsMap.put("area_id", area_id);
				int is_municipal = helpService.getIs_municipalByProvince_id(province_id);
				if (is_municipal == 1) {
					paramsMap.put("t_hospital", Constants.T_HOSPITAL + province_id);
					List<Hospital> list = null;
					try {
						list = pcService.findHospitalByRetrieve(paramsMap);
					} catch (Exception e) {
						log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
						return resultMap = MapModel.getMapModel("0", list, "正在建设中，请耐心等待！");
					}
					for (Hospital h : list) {
						String h_id = province_id + h.getHospital_id();
						h.setHospital_id(h_id);
					}
					resultMap = MapModel.getMapModel("1", list, "");
				} else {
					paramsMap.put("t_hospital", Constants.T_HOSPITAL + c_id);
					List<Hospital> list = null;
					try {
						list = pcService.findHospitalByRetrieve(paramsMap);
					} catch (Exception e) {
						log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
						return resultMap = MapModel.getMapModel("0", list, "正在建设中，请耐心等待！");
					}
					for (Hospital h : list) {
						String h_id = c_id + h.getHospital_id();
						h.setHospital_id(h_id);
					}
					resultMap = MapModel.getMapModel("1", list, "");
					return resultMap;
				}
			} else {
			}
		} catch (Exception e1) {
			resultMap = MapModel.getMapModel("0", "", "用户名异常");
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			return resultMap;
		}
		return resultMap;
	}

	*//**
	 * 2.6 Pc 监察单位查询辖区 被 检察单位详细信息 请求方式 ：GET 参数 ：partID : 单位ID , Key 软件秘钥 ,
	 * WatchID 被检察单位 ID
	 * 
	 * @return 0 不成功 list(2--14) 空 , 1 成功 list(2--14) 给值 2:Address Partstyle
	 *         Contacts Tel Corporate Certificate Cernumber Permits PerValidity
	 *         BusnissRecordno OrganizationCode Divsion GPSx GPSy
	 * 
	 *//*
	@RequestMapping(value = "getHospitalByHospitalID", method = RequestMethod.GET)
	public Map<String, Object> getHospitalByHospitalID(String PartID, String Key, String WatchID) {
		log.info("PC接口 :2.6 " + DateUtil.getTime());
		// 处理空格
		PartID = PartID.replace(" ", "");
		// 处理PartID 大小写
		Map<String, Object> resultMap = null;
		try {
			PartID = HelpUtil.TreateEmployerID(PartID);
			Employers employers = null;
			employers = pcService.findEmployersById(PartID);
			if (null == employers) {
				resultMap = MapModel.getMapModel("0", "", "单位不存在");
				return resultMap;
			}
			if (!employers.getKey().equals(Key)) {
				resultMap = MapModel.getMapModel("0", "", "秘钥不合法");
				return resultMap;
			}
			Map<String, Object> paramsMap = new HashMap<String, Object>();
			String city_id = WatchID.substring(0, 6).toString();
			String hospital_id = WatchID.substring(6).toString();
			paramsMap.put("hospital_id", hospital_id);
			paramsMap.put("t_hospital", Constants.T_HOSPITAL + city_id);
			Hospital hospital = null;
			try {
				hospital = pcService.findHospitalByID(paramsMap);
			} catch (Exception e) {
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				resultMap = MapModel.getMapModel("0", "", "正在建设中，请耐心等待！");
				return resultMap;
			}
			if (null == hospital) {
				resultMap = MapModel.getMapModel("0", "", "单位不存在");
				return resultMap;
			}
			resultMap = MapModel.getMapModel("1", hospital, "");
		} catch (Exception e1) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			resultMap = MapModel.getMapModel("0", "", "用户名异常");
			return resultMap;
		}
		return resultMap;
	}


	

	
	


}
*/